#include "common.h"
#include "em_timer.h"
#include "em_cmu.h"
#include "app_task.h"
#include "version.h"
#include "app_reserve_day.h"
#include "shell.h"
void Timer1Init(void)
{
    // Enable clock for TIMER0 module
    CMU_ClockEnable(cmuClock_TIMER1, true);

    // Initialize the timer
    TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
    timerInit.prescale = timerPrescale1024;
    timerInit.sync = true;
    timerInit.enable = false;
    TIMER1->CNT = 0;
    TIMER_Init(TIMER1, &timerInit);
    TIMER_TopSet(TIMER1, 37499);
    // Enable TIMER0 compare event interrupts to update the duty cycle
    TIMER_IntEnable(TIMER1, TIMER_IEN_OF);
    NVIC_EnableIRQ(TIMER1_IRQn);
    TIMER_Enable(TIMER1, true);
}

void TIMER1_IRQHandler(void)
{
    uint32_t flags = TIMER_IntGet(TIMER1);
    TIMER_IntClear(TIMER1, flags);
//    flash_operation_t operation;
//    operation.type = FLASH_TIME_REMAIN;
//    operation.time_remain = 1;
//    flash_operation_notify(operation);
    RunningTimeHandler();
    reserved_days_handler();

}





